import request from '@/utils/request'

/**
 * @description 获取漏洞验证记录列表
 * @param {Object} params - 查询参数，包含页码、每页数量、时间范围、状态等
 * @returns {Promise} Promise 对象
 */
export function getVulnVerificationRecords(params) {
  return request({
    url: '/api/vulnVerification/records',
    method: 'get',
    params
  })
}

/**
 * @description 获取漏洞验证记录详情
 * @param {string|number} id - 记录ID
 * @returns {Promise} Promise 对象
 */
export function getVulnVerificationDetail(id) {
  return request({
    url: `/api/vulnVerification/detail/${id}`,
    method: 'get'
  })
}

/**
 * @description 创建漏洞验证记录
 * @param {Object} data - 记录数据
 * @returns {Promise} Promise 对象
 */
export function createVulnVerificationRecord(data) {
  return request({
    url: '/api/vulnVerification/create',
    method: 'post',
    data
  })
}

/**
 * @description 更新漏洞验证记录
 * @param {Object} data - 记录数据
 * @returns {Promise} Promise 对象
 */
export function updateVulnVerificationRecord(data) {
  return request({
    url: '/api/vulnVerification/update',
    method: 'post',
    data
  })
}

/**
 * @description 删除漏洞验证记录
 * @param {string|number} id - 记录ID
 * @returns {Promise} Promise 对象
 */
export function deleteVulnVerificationRecord(id) {
  return request({
    url: `/api/vulnVerification/delete/${id}`,
    method: 'post'
  })
}

/**
 * @description 获取文档模板列表
 * @returns {Promise} Promise 对象
 */
export function getDocumentTemplates() {
  return request({
    url: '/api/vulnVerification/templates',
    method: 'get'
  })
}

/**
 * @description 获取文档模板详情
 * @param {string|number} id - 模板ID
 * @returns {Promise} Promise 对象
 */
export function getDocumentTemplateDetail(id) {
  return request({
    url: `/api/vulnVerification/template/${id}`,
    method: 'get'
  })
}

/**
 * @description 创建文档模板
 * @param {Object} data - 模板数据
 * @returns {Promise} Promise 对象
 */
export function createDocumentTemplate(data) {
  return request({
    url: '/api/vulnVerification/template/create',
    method: 'post',
    data
  })
}

/**
 * @description 更新文档模板
 * @param {Object} data - 模板数据
 * @returns {Promise} Promise 对象
 */
export function updateDocumentTemplate(data) {
  return request({
    url: '/api/vulnVerification/template/update',
    method: 'post',
    data
  })
}

/**
 * @description 删除文档模板
 * @param {string|number} id - 模板ID
 * @returns {Promise} Promise 对象
 */
export function deleteDocumentTemplate(id) {
  return request({
    url: `/api/vulnVerification/template/delete/${id}`,
    method: 'post'
  })
}

/**
 * @description 获取文档访问控制规则列表
 * @returns {Promise} Promise 对象
 */
export function getDocumentAccessRules() {
  return request({
    url: '/api/vulnVerification/access-rules',
    method: 'get'
  })
}

/**
 * @description 创建文档访问控制规则
 * @param {Object} data - 规则数据
 * @returns {Promise} Promise 对象
 */
export function createDocumentAccessRule(data) {
  return request({
    url: '/api/vulnVerification/access-rule/create',
    method: 'post',
    data
  })
}

/**
 * @description 更新文档访问控制规则
 * @param {Object} data - 规则数据
 * @returns {Promise} Promise 对象
 */
export function updateDocumentAccessRule(data) {
  return request({
    url: '/api/vulnVerification/access-rule/update',
    method: 'post',
    data
  })
}

/**
 * @description 删除文档访问控制规则
 * @param {string|number} id - 规则ID
 * @returns {Promise} Promise 对象
 */
export function deleteDocumentAccessRule(id) {
  return request({
    url: `/api/vulnVerification/access-rule/delete/${id}`,
    method: 'post'
  })
}

/**
 * @description 导出验证记录为PDF
 * @param {string|number} id - 记录ID
 * @returns {Promise} Promise 对象
 */
export function exportVerificationRecordPDF(id) {
  return request({
    url: `/api/vulnVerification/export/${id}`,
    method: 'get',
    responseType: 'blob'
  })
}

/**
 * 获取漏洞验证环境列表
 * @param {Object} params - 查询参数
 * @returns {Promise}
 */
export function getVulnEnvironmentList(params) {
  return request({
    url: '/vuln-environment/list',
    method: 'get',
    params
  })
}

/**
 * 添加漏洞验证环境
 * @param {Object} data - 环境信息
 * @returns {Promise}
 */
export function addVulnEnvironment(data) {
  return request({
    url: '/vuln-environment/add',
    method: 'post',
    data
  })
}

/**
 * 更新漏洞验证环境
 * @param {Object} data - 环境信息
 * @returns {Promise}
 */
export function updateVulnEnvironment(data) {
  return request({
    url: '/vuln-environment/update',
    method: 'put',
    data
  })
}

/**
 * 删除漏洞验证环境
 * @param {string|number} id - 环境ID
 * @returns {Promise}
 */
export function deleteVulnEnvironment(id) {
  return request({
    url: `/vuln-environment/delete/${id}`,
    method: 'delete'
  })
}

/**
 * 获取环境配置
 * @param {string|number} id - 环境ID
 * @returns {Promise}
 */
export function getVulnEnvironmentConfig(id) {
  return request({
    url: `/vuln-environment/config/${id}`,
    method: 'get'
  })
}

/**
 * 保存环境配置
 * @param {Object} data - 配置信息
 * @returns {Promise}
 */
export function saveVulnEnvironmentConfig(data) {
  return request({
    url: '/vuln-environment/config/save',
    method: 'post',
    data
  })
}

/**
 * 获取验证监控信息
 * @param {string|number} id - 环境ID
 * @returns {Promise}
 */
export function getVulnVerificationMonitor(id) {
  return request({
    url: `/vuln-verification/monitor/${id}`,
    method: 'get'
  })
}

/**
 * 获取验证记录列表
 * @param {Object} params - 查询参数
 * @returns {Promise}
 */
export function getVerificationRecordList(params) {
  return request({
    url: '/vuln-verification/record/list',
    method: 'get',
    params
  })
}

/**
 * 批量删除验证记录
 * @param {Array} ids - 记录ID数组
 * @returns {Promise}
 */
export function batchDeleteVerificationRecords(ids) {
  return request({
    url: '/vuln-verification/record/batch-delete',
    method: 'delete',
    data: { ids }
  })
}

/**
 * 导出验证记录
 * @param {Object} params - 导出参数
 * @returns {Promise}
 */
export function exportVerificationRecords(params) {
  return request({
    url: '/vuln-verification/record/export',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

/**
 * 获取验证记录详情
 * @param {string|number} id - 记录ID
 * @returns {Promise}
 */
export function getVerificationRecordDetail(id) {
  return request({
    url: `/vuln-verification/record/detail/${id}`,
    method: 'get'
  })
}

/**
 * 获取文档模板列表
 * @param {Object} params - 查询参数
 * @returns {Promise}
 */
export function getDocumentTemplateList(params) {
  return request({
    url: '/vuln-verification/document/template/list',
    method: 'get',
    params
  })
}

/**
 * 获取漏洞详情
 * @returns {Promise} Promise 对象
 */
export function getVulnDetail(params) {
  return request({
    url: "/vuln_db/verify_info/",
    method: "GET",
    params
  });
}

/**
 * 获取漏洞详情
 * @returns {Promise} Promise 对象
 */
export function getVulnDetailById(params) {
  return request({
    url: "/vuln_db/vuln_info/",
    method: "GET",
    params
  });
}
